package com.kk.quyan.controller;

import com.kk.quyan.common.R;
import com.kk.quyan.entity.request.RelRequest;
import com.kk.quyan.service.MaterialLabelRelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 关系接口
 * @author: Kk
 * @create: 2020-11-22 10:44
 **/
@Api(value = "RelController" ,description = "关系测试接口")
@RestController
@RequestMapping("rel")
public class RelController {

    @Autowired
    private MaterialLabelRelService materialLabelRelService;

    @ApiOperation(value = "插入素材与添加对应标签关系")
    @PostMapping("addRel")
    public R addRel(@RequestBody RelRequest relRequest){
        boolean flag = materialLabelRelService.saveMaterialRel(relRequest);
        return flag?R.ok("插入成功"):R.error("插入失败");
    }

    @ApiOperation(value = "添加素材与标签关系")
    @PostMapping("addRel/{mId}/{lId}")
    public R addRel(@PathVariable("mId")int mId,@PathVariable("lId")int lId){
        materialLabelRelService.saveRel(mId,lId);
        return R.ok();
    }
}
